public class Solution781 {
    public int numRabbits(int[] answers) {
        int[] f=new int[1005];
        for (int answer : answers) {
            f[answer]++;
        }
        int ans=0;
        for (int i=0;i<1000;i++){
            ans=ans+((int)Math.ceil(f[i]/(i+1.0)))*(i+1);
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution781().numRabbits(new int[]{1,1,2}));
    }
}
